package com.hotel.suqiang.dingdonegurad;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import com.hotel.suqiang.dingdonegurad.ui.SettingView;
import com.hotel.suqiang.dingdonegurad.utils.Contants;
import com.hotel.suqiang.dingdonegurad.utils.SharedPreferencesUtis;

public class SettingActivity extends AppCompatActivity {

    private SettingView updateSettingView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);

        boolean isAutoUpdate = SharedPreferencesUtis.getBoolean(this, Contants.SETTING_UPDATE_KEY, true);

        updateSettingView = (SettingView) findViewById(R.id.setting_auto_update_switch);
        updateSettingView.setToggle(isAutoUpdate);
        updateSettingView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                updateSettingView.toggle();

                SharedPreferencesUtis.saveBoolean(SettingActivity.this, Contants.SETTING_UPDATE_KEY, updateSettingView.getToggle());
            }
        });
    }
}
